<template>
  <div class="mbleague_entry">
    <div class="mobile_entry_header">
      <van-nav-bar class="main_header" :title="gameInfo.name" left-arrow @click-left="goback()" />
    </div>

    <div class="mobile_entry_content_wrap">
      <router-view :game-info="gameInfo" />
    </div>
  </div>
</template>

<script>
import { api_GET_EventsManagementCompetitionWithRoute } from '@/extend/api/gameswaggerApi/app';
export default {
  name: 'MBleagueEntry',
  data () {
    return {
      gameRoute: '',
      gameTenantId: '',
      gameInfo: {}
    };
  },
  created() {
    const _paramsId = this.$route.params.id;
    this.gameRoute = _paramsId.split('_')[0];
    // 因为短域名原因手动添加VUE_APP_Get_TenantId
    this.gameTenantId = process.env.VUE_APP_Get_TenantId;;
    this.getGameInfo();
  },
  methods: {
    // 获取赛事详情
    getGameInfo() {
      const gameQO = {};
      gameQO.route = this.gameRoute;
      gameQO.IncludeStatus = true;
      gameQO.IncludeType = true;
      gameQO.IncludeApproveStatus = true;
      gameQO.IncludeApproveStatus = true;
      gameQO.IncludeLevel = true;
      gameQO.IncludeSetting = true;
      gameQO.IncludeReportSetting = true;
      gameQO.IncludeEntryFields = true;
      gameQO.IncludeParent = true;
      this.getGameInfoByGameRoute(gameQO);
    },
    // 根据赛事路由获取赛事信息
    getGameInfoByGameRoute(gameQO) {
      this.gameLoading = true;
      api_GET_EventsManagementCompetitionWithRoute(gameQO)
        .then(res => {
          this.gameLoading = false;
          this.gameInfo = res || {};
          this.title = this.gameInfo.name || this.title;
          this.gameId = this.gameInfo.id;
        });
    },
    goback() {
      this.$router.push({
        name: 'HomeGame'
      });
    }
  }
};
</script>

<style>
.mbleague_entry .van-nav-bar .van-icon {
  color: #666;
}
</style>

<style lang="scss" scoped>
.mbleague_entry {
  width: 100%;
  height: 100%;
  background-color: #fcfcfc;
}

.mobile_entry_header {
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
}
.mobile_entry_content_wrap {
  position: absolute;
  width: 100%;
  top: 46px;
  bottom: 0px;
  overflow: scroll;
  background-color: #fcfcfc;
}
</style>
